package com.yunfei.fegin;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.TimeUnit;

/**
* @Description:  定义一个feign接口，通过@ FeignClient（“服务名”），来指定调用哪个服务。比如在代码中调用了service-hi服务的“/hi”接口，代码如下：
 * Feign中使用断路器：只需要在FeignClient的SchedualServiceHi接口的注解中加上fallback的指定类就行了
* @Author: zhengyunfei q群号:541122375
* @Date: 2018/7/3  
* @time:11:05
*/
@FeignClient(value="app-redis-center",fallback = RedisServiceHystric .class)
public interface RedisService {

    @RequestMapping(value = "/get",method = RequestMethod.GET)
    String get(@RequestParam(value = "key", required = false) String key);
    @RequestMapping(value = "/exists",method = RequestMethod.GET)
    boolean exists(@RequestParam(value = "key", required = false) String key);
    @RequestMapping(value = "/set",method = RequestMethod.GET)
    boolean set(@RequestParam(value = "key", required = false) String key, @RequestParam(value = "value", required = false) Object value);

    @RequestMapping(value = "/set1",method = RequestMethod.GET)
    boolean set1(@RequestParam(value = "key", required = false) String key, @RequestParam(value = "value", required = false) Object value, @RequestParam(value = "time", required = false) long time);

    @RequestMapping(value = "/set2",method = RequestMethod.GET)
    boolean set2(@RequestParam(value = "key", required = false) String key, @RequestParam(value = "value", required = false) Object value, @RequestParam(value = "time", required = false) long time, @RequestParam(value = "timeUnit", required = false) TimeUnit timeUnit);

    @RequestMapping(value = "/getExpireTime",method = RequestMethod.GET)
    String getExpireTime(@RequestParam(value = "key", required = false) String key);

    @RequestMapping(value = "/remove",method = RequestMethod.GET)
    boolean remove(@RequestParam(value = "key", required = false) String key);

}
